package mani.threads;

public class InterruptThread implements Runnable{
	public void run(){
		long number = 1L;
		while(true){
			if(isPrime(number)){
				System.out.printf("Number %d is prime\n", number);
			}
			if(Thread.currentThread().isInterrupted()){
				System.out.println("The thread has been interuppted");
				return;
			}
			number++;
		}
	}

	private boolean isPrime(long number) {
		if(number<2){
			return true;
		}
		for(long i =2; i<=number;i++){
			if((number%i)==0){
				return false;
			}
		}
		return true;
	}
}
